<?php

require_once('../../../system.php');
require_once($GO_LANGUAGE->get_language_file('cms'));
$cms_module = $GO_MODULES->get_module('cms');

if(isset($_REQUEST['site_id']) && $cms_module)
{
  require_once($cms_module['class_path'].'cms.class.inc');
  require_once($cms_module['class_path'].'cms_site.class.inc');
  $cms_site = new cms_site($_REQUEST['site_id']);
}

if(isset($cms_site) && $cms_site)
{
  echo $cms_site->generate_header();
  
	$email_to = $cms_site->site['webmaster'];
}else
{  
	$email_to = $GO_CONFIG->webmaster_email;
	require_once($GO_THEME->theme_path."header.inc");
}

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
  $name_from = smart_stripslashes(trim($_POST['name_from']));
  $email_from = smart_stripslashes(trim($_POST['email_from']));
  $subject = smart_stripslashes(trim($_POST['subject']));  
  $mail_body = smart_stripslashes(trim($_POST['mail_body']));
  if ($name_from == '' || $email_from == '' || $subject == '' || $mail_body == '')
  {
    $feedback = '<p class="Error">'.$error_missing_field.'</p>';
  }elseif(!validate_email($email_from))
  {
    $feedback = '<p class="Error">'.$error_email.'</p>';
  }else
  {
    if(!sendmail($email_to, $email_from, $name_from, $subject, $mail_body))
	{
	  $feedback = '<p class="Error">'.$cms_sendmail_error.'</p>';
	}else
	{
	  echo $cms_sendmail_success;
	  require_once($GO_THEME->theme_path."footer.inc");
	  exit();	
	}    
  }
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" name="register">
<input type="hidden" name="site_id" value="<?php echo $_REQUEST['site_id']; ?>" />
<?php if (isset($feedback)) echo $feedback; ?>
<table border="0">
<tr>
<td align="right" nowrap>
<?php echo $strName; ?>:
</td>
<td>
<input type="text" name="name_from" size="40" style="width: 400px;" value="<?php if(isset($_POST['name_from'])) echo $_POST['name_from']; ?>" maxlength="50">
</td>
</tr>
<tr>
<td align="right" nowrap valign="top">
<?php echo $strEmail; ?>:
</td>
<td class="small">
<input type="text" name="email_from" style="width: 400px;" value="<?php if(isset($_POST['email_from'])) echo $_POST['email_from']; ?>" maxlength="75"><br />
</td>
</tr>
<tr>
<td align="right" nowrap valign="top">
<?php echo $cms_subject; ?>:
</td>
<td class="small">
<input type="text" name="subject" style="width: 400px;" value="<?php if(isset($_POST['subject'])) echo $_POST['subject']; ?>" maxlength="75"><br />
</td>
</tr>
<tr>
<td align="right" nowrap valign="top">
<?php echo $cms_message; ?>:
</td>
<td>
<textarea name="mail_body" style="width: 400px;height: 220px;"><?php if(isset($_POST['mail_body'])) echo $_POST['mail_body']; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="<?php echo $cmdOk; ?>" style="width:100px"; />
&nbsp;&nbsp;
<input type="reset" value="<?php echo $cmdReset; ?>" style="width:100px"; />
</td>
</tr>
</table>
<?php
if(isset($cms_site) && $cms_site)
{
  $cms_site->generate_footer();
}else
{
  require_once($GO_THEME->theme_path."footer.inc");
}
